//
//  FSArticleViewController.m
//  fanshu
//
//  Created by mh on 16/3/27.
//  Copyright © 2016年 FS. All rights reserved.
//

#import "FSArticleViewController.h"

#import "FSScrollerView.h"
#import "FSDisCoverFrameModel.h"
@interface FSArticleViewController ()
@property(nonatomic,strong)FSScrollerView *scrollerView;

@end

@implementation FSArticleViewController
#pragma mark - 属性懒加载
- (FSScrollerView *)scrollerView{
    if (_scrollerView == nil) {
        FSScrollerView *scrollerView = [[FSScrollerView alloc] init];
        scrollerView.frame = CGRectMake(0, 0, ScreenWidth, 150);
        _scrollerView = scrollerView;
    }
    return _scrollerView;
}
#pragma  mark - 系统方法
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //设置图片轮播器
    [self setScrollerView];
}

- (void)viewDidLoad {
    [super viewDidLoad];

    //添加模型数组
    [self addModel];
    
}

#pragma  mark - 初始化方法
//添加模型数组
- (void)addModel{
    FSDiscoverArticleModel *model = [[FSDiscoverArticleModel alloc] init];
    model.icon = @"icon_personal_qq";
    model.name = @"呵呵";
    model.time = @"刚刚";
    model.title = @"这个是那个啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥";
    model.type = @"个人";
    model.countOfRead = @"14";
    model.countOfComment = @"998";
    model.countOfLike = @"1000";
    model.image = @"guide_p3_img";
    FSDisCoverFrameModel *frameModel = [[FSDisCoverFrameModel alloc] init];
    frameModel.model = model;
    [self.dataArray addObject:frameModel];
    [self.dataArray addObject:frameModel];
    [self.dataArray addObject:frameModel];
    [self.dataArray addObject:frameModel];
    [self.dataArray addObject:frameModel];
}
//按钮点击Block
- (void)setScrollerToolBar:(FSScrollerToolBar *)scrollerToolBar{
    [super setScrollerToolBar:scrollerToolBar];
    self.scrollerToolBar.btnOnClick = ^(FSButton *btn){
        if (![btn.titleLabel.text isEqualToString:@"热门"]) {
            self.tableView.tableHeaderView = nil;
            [self.scrollerView stopTimer];
        }else{
            self.tableView.tableHeaderView = self.scrollerView;
            [self.scrollerView startTimer];
        }
    };
}

//添加图片轮播器
- (void)setScrollerView{
    //设置图片的数组   图片名字  后期改为URL
    NSArray *arr = @[@"guide_im_reader",@"guide_p1_img",@"guide_im_writer",@"guide_p1_word",@"guide_p4_img"];
    self.scrollerView.imageArray = arr;
    [UIView animateWithDuration:0.3f animations:^{
        self.tableView.tableHeaderView = self.scrollerView;
    }];
}
@end
